package com.shangxia.leetcode.hoot100.easy;

import lombok.extern.slf4j.Slf4j;

/**
 * @ProjectName: leetcode
 * @ClassName: MergeTrees617
 * @Time: 2020/11/30
 * @Author: zhouy
 * @Description:
 * @Experience:
 */

@Slf4j
public class MergeTrees617 {

    public static void main(String[] args) {

    }


    public static TreeNode mergeTrees(TreeNode t1, TreeNode t2) {
        if (null == t1) {
            return t2;
        }
        if (null == t2) {
            return t1;
        }
        TreeNode treeNode = new TreeNode(t1.val + t2.val);
        treeNode.left = mergeTrees(t1.left, t2.left);
        treeNode.right = mergeTrees(t1.right, t2.right);
        return treeNode;
    }

    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }
}
